package com.okilo.online.app.apt

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.okilo.online.app.R
import com.okilo.online.app.tools.apt.OkiloRecyclerViewAdapter
import com.okilo.online.app.tools.apt.OkiloViewHolderHelper
import org.json.JSONObject

/**
 * OkiloLoan
 * @Author wwdeng
 * @CreateTime: 2025/3/10 20:14
 * @Annotation：进件信息 - 选择Popupwindow item
 */
class OkiloSelectPopupApt(recyclerView: RecyclerView?) : OkiloRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.okilo_popup_select_item) {
    override fun setItemChildListener(helper: OkiloViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.okiloSelectPopupItem) //点击Item
    }
    override fun fillData(helper: OkiloViewHolderHelper, position: Int, model: JSONObject) {
        val okiloSelectPopupTitle = helper.getTextView(R.id.okiloSelectPopupTitle)
        okiloSelectPopupTitle.text = model.optString("title")

        val okiloSelectPopupStatus = helper.getImageView(R.id.okiloSelectPopupStatus)
        if (model.optBoolean("isSelect",false)) {
            okiloSelectPopupStatus.setImageResource(R.mipmap.okilo_ulog_pp_check_selected)
        } else {
            okiloSelectPopupStatus.setImageResource(R.mipmap.okilo_ulog_pp_check_normal)
        }
        if (position == itemCount - 1){
            helper.setVisibility(R.id.okiloSelectPopupLine, View.INVISIBLE)
        } else {
            helper.setVisibility(R.id.okiloSelectPopupLine, View.VISIBLE)
        }
    }
}